package com.itheima.fanshe;

import com.itheima.domain.Student;
import com.itheima.domain.Worker;

import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Properties;
/*
动态执行类的方法
 */
public class Demo01 {

    public static void main(String[] args) throws Exception {
     /*   Student student = new Student();
        student.study();
*/
   /*     Worker worker = new Worker();
        worker.work();*/
        Properties prop = new Properties();
        prop.load(ClassLoader.getSystemResourceAsStream("prop.properties"));
        Class<?> clazz = Class.forName(prop.getProperty("className"));
        Object o = clazz.getConstructor().newInstance();
        String methoName = prop.getProperty("methodName");
        Method method = clazz.getMethod(methoName);
        method.invoke(o);

    }
}
